/**
 * 实现esp8266发送数据给arduion实现led灯的闪亮
 */

 #include <SoftwareSerial.h>


 
#include <ArduinoJson.h>
#include <ESP8266WiFi.h> //ESP8266 Library
const char* ssid = "thh123"; //Enter your Wi-Fi SSID
const char* password = "123123123"; //Enter you Wi-Fi Password
int i=0;

void setup() {
    Serial.begin(9600);
//    WiFi.begin(ssid, password); //connect to the network specified above
}
 
void loop() {
  if(i==0){
     Serial.print(sendJson("0"));//发送数据给arduino
    i=1;
    }else{
     Serial.print(sendJson("1"));//发送数据给arduino
    i=0;
  }
  delay(5000);
}
 
String sendJson(String data){
const size_t capacity = JSON_OBJECT_SIZE(1)+10;
DynamicJsonDocument doc(capacity);
doc["7"] = data;
String josn;
serializeJson(doc, josn);
return  josn;
  }
